<!DOCTYPE html>
<html lang="en">

<include file="CommonSidebar:common-head"/>
<link rel="stylesheet" href="__ROOT__/Application/Home/Public/css/common.css">
<link href="__ROOT__/Application/Home/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<body>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">所有商品</h1>
            </div>
        </div>
        <div class="alert alert-success" role="alert">
            <button class="alert-link bindbutt">更新库存</button>
        </div>

        <div class="alert alert-success" role="alert">
            <button class="alert-link bindbutt1">快速更新库存（只更新库存少于100）</button>
        </div>

    </div>
</div>
<!-- /#wrapper -->

<div class="modal fade dialogsecc" id="myModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header" style="height:30px;">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"></h4>
            </div>
            <div class="modal-body">
                <div class="progress" style="    background: #CCC;    margin: 0;    height: 50px;    border-radius: 0;">
                    <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0"
                         aria-valuemax="100" style="width: 60%; ">
                        60%
                    </div>
                </div>
            </div>
            <div class="modal-footer" style="height:30px;">

            </div>
        </div>
    </div>
</div>

<include file="CommonSidebar:common-script"/>
<script src="__ROOT__/Application/Home/Public/js/jquery.datetimepicker.js"></script>
<!-- DataTables JavaScript -->
<script src="__ROOT__/Application/Home/Public/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="__ROOT__/Application/Home/Public/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="__ROOT__/Application/Home/Public/dist/js/sb-admin-2.js"></script>
<!-- Page-Level Demo Scripts - Tables - Use for reference -->


<script type="text/javascript" src="__ROOT__/Application/Home/Public/LoadPading/LoadPading.js?v=3"></script>
<link rel="stylesheet" href="__ROOT__/Application/Home/Public/LoadPading/LoadPading.css" type="text/css"
      media="screen"/>


<script>
    $(document).ready(function () {
        $('#dataTables-example').DataTable({
            responsive: true
        });
    });
</script>


<script>
    $('.bindbutt').click(function () {
        if (confirm("批量更新数据后，原数据就改变？是否确认")) {
            var datacount = {$datacount};
            ajaxing(datacount);
        }
    });
    function ajaxing(datacount) {
        alert("总共更新数据:" + datacount + "条");
        ajaxing2(0, datacount);
    }
    function ajaxing2(id, datacount) {
        var jdd = ((id / datacount) * 100);
        $(".progress-bar").html(jdd.toFixed(1) + '%').width(jdd + '%');
        if (id < datacount) {
            $("#myModal").modal();
            $.post("{:U('/Goods/AjaxUpdateGoods')}",
                    {id: id},
                    function (data) {
                        setTimeout(ajaxing2((id + 1), datacount), 300);
                    });
        } else {
            location.href = "{:U('Goods/UpdateRes')}";
            return false;
        }
    }
</script>
<script>
    //快速更新
    $('.bindbutt1').click(function () {
        if (confirm("批量更新数据后，原数据就改变？是否确认")) {
            var ksdatacount = {$ksdatacount};
            ajaxingks(ksdatacount);
        }
        function ajaxingks(ksdatacount) {
            alert("总共更新数据:" + ksdatacount + "条");
            ajaxingks2( 0, ksdatacount);
        }
        function ajaxingks2(id, ksdatacount) {
            var jdd = ((id / ksdatacount) * 100);
            $(".progress-bar").html(jdd.toFixed(1) + '%').width(jdd + '%');
            if (id < ksdatacount) {
                $("#myModal").modal();
                $.post("{:U('/Goods/AjaxUpdateGoodsks')}",
                        {id: id},
                        function (data) {
                            setTimeout(ajaxingks2((id + 1), ksdatacount), 300);
                        });
            } else {
                location.href = "{:U('Goods/UpdateRes')}";
                return false;
            }
        }
    });
</script>
</body>

</html>
